import { createRouter, createWebHistory } from 'vue-router'
import HomeView from '@/views/home/HomeView.vue'
import adminView from '@/views/admin/adminView.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '',
      name: 'home',
      component: HomeView,
      children: [
        {
          path: "//:categoryid?",
          name: "index",
          component: () => import("@/views/home/index.vue")
        },
        {
          path: "/article/:id",
          name: "article",
          component: () => import("@/views/home/article.vue")
        },
        {
          path: "/nav",
          name: "nav",
          component: () => import("@/views/home/nav.vue")
        },
        {
          path: "/search/:name/:type/:value",
          name: "search",
          component: () => import("@/views/home/search.vue")
        }
      ]
    },
    {
      path: '/admin/login',
      name: 'login',
      component: () => import("@/views/admin/login.vue")
    },
    {
      path: '/admin/',
      name: 'admin',
      component: adminView,
      children: [
        {
          path: "home",
          name: "adminHome",
          component: () => import("@/views/admin/index.vue")
        },
        {
          path: 'article',
          name: 'adminArticle',
          component: () => import("@/views/admin/article.vue")
        },
        {
          path: 'article/write/:id?',
          name: 'adminArticleWrite',
          component: () => import("@/views/admin/articleWrite.vue")
        },
        {
          path: 'category',
          name: 'adminCategory',
          component: () => import("@/views/admin/category/category.vue")
        },
        {
          path: 'tag',
          name: 'adminTag',
          component: () => import("@/views/admin/tag/tag.vue")
        }
      ]
    }

  ]
})

export default router
